package com.adolph.netty.nettydemo;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;

/**
 * 〈功能概述〉<br>
 * 心跳检测handler
 * @author: wangxiangjun
 * @date: 2020-10-13 22:11
 */

public class HeartbeatHandler extends ChannelInboundHandlerAdapter {

    //
    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {

        //长时间没链接时触发事件
        if(evt instanceof IdleStateEvent){
            //发送心跳消息给客户端
        }else{
            super.userEventTriggered(ctx, evt);
        }


    }
}
